package hanqi.jdbc;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CustomerController {
    @Autowired
    CustomerServiceImpl customerService;
    @GetMapping("/save")
    public String saveCustomer() {
        Customer customer = new Customer();
        customer.setJobNo("J00353");
        customer.setName("Jack");
        customer.setDepartment("软件学院");
        int result=customerService.saveCustomer(customer);
        if(result>0) {
            return "success";
        }
        else {
            return "fail";
        }
    }
    @GetMapping("/getCustomer/{id}")
    public Customer getCustomerById(@PathVariable Integer id) {
        return customerService.getCustomerById(id);
    }

}
